import psutil

def get_system_info():
    # 获取CPU信息
    cpu_percent = psutil.cpu_percent(interval=1)
    
    # 获取内存信息
    memory_info = psutil.virtual_memory()
    memory_total = memory_info.total
    memory_used = memory_info.used
    memory_free = memory_info.free
    memory_percent = memory_info.percent
    
    # 获取磁盘信息
    disk_info = psutil.disk_usage('/')
    disk_total = disk_info.total
    disk_used = disk_info.used
    disk_free = disk_info.free
    disk_percent = disk_info.percent

    return {
        "cpu": cpu_percent,
        "memory": {
            "total": memory_total,
            "used": memory_used,
            "free": memory_free,
            "percent": memory_percent
        },
        "disk": {
            "total": disk_total,
            "used": disk_used,
            "free": disk_free,
            "percent": disk_percent
        }
    }

if __name__ == "__main__":
    system_info = get_system_info()
    
    print(f"CPU Usage: {system_info['cpu']}%")
    print(f"Memory Total: {system_info['memory']['total'] / (1024**3):.2f} GB")
    print(f"Memory Used: {system_info['memory']['used'] / (1024**3):.2f} GB")
    print(f"Memory Free: {system_info['memory']['free'] / (1024**3):.2f} GB")
    print(f"Memory Usage: {system_info['memory']['percent']}%")
    print(f"Disk Total: {system_info['disk']['total'] / (1024**3):.2f} GB")
    print(f"Disk Used: {system_info['disk']['used'] / (1024**3):.2f} GB")
    print(f"Disk Free: {system_info['disk']['free'] / (1024**3):.2f} GB")
    print(f"Disk Usage: {system_info['disk']['percent']}%")